[v7r2] Run pytest test collection for Python 3#4718
Conversation
| import time | ||
| import select | ||
| import cStringIO | ||
| from six import BytesIO |
There was a problem hiding this comment.
I didn't check, but when StringIO or BytesIO`?
There was a problem hiding this comment.
It's analogous to opening a file with open(filename, mode="wt") and open(filename, mode="wb") though Python 2 doesn't do a very good job teaching you to think about the difference.
StringIOshould be used when you want something you would open in a text editor: XML files, JDL, HTML.BytesIOshould be used when you just want a bag of bytes such as a compressed tarfile or an image. Also if you want to hash something with md5, you need bytes as different encodings will result in different hashes.
I think I've got these correct but we'll only know for sure when we start executing tests. I have a draft branch locally which gets 80% of them passing so I'll make a PR to start executing tests as soon as this PR is merged.
Co-authored-by: fstagni <federico.stagni@cern.ch>
225f119 to
305202c
Compare
|
For |
|
Argh !! When commenting a specific commit, it does not display it nicely.... 😢 |
It's not so bad. You can click the filename in the heading bar to get to the conversation view which I think works better than a huge "changes" view on the PR tab. |
Somehow on the other PR it worked, while I don't think I've done anything different... weird |
This PR adds
pytest --collect-onlyto the CI for Python 3 and none of the changes should make a difference in Python 2. More changes will be needed before the tests work but this will at least ensure that it's possible to import most of DIRAC. All of the changes should be transparent in Python 2 and future PRs can then start enabling parts of the unit tests by adding-k myteststo the command.I've constructed it to be easy to review as individual commits instead of in one go. I've split them into two groups:
Simple renaming of modules that is handled using
sixsix.StringIOandsix.BytesIOare bothStringIO.StringIO. In Python 3 they areio.StringIOandio.BytesIObut it's not practical to use these in Python 2 as StringIO requires unicode objects as input which isn't worth it. I've tried to guess at which one will be appropriate for Python 3 but more changes will definitely be needed here to make the tests pass once they're being executed.Other changes
subprocess.getstatusoutputforcommands.getstatusoutputsubprocess32properly rather than using the long-deprecatedgetstatusoutput. (thesubprocess32doesn't include Python 3'ssubprocess.getstatusoutput)dirac-installwill force people to get Python 2.7 from DIRACOS.MySQL-pythonwas abandoned a long time ago and never supported Python 3. It looks likemysqlclientis almost a drop in replacement so that's what I've gone with for now. The only change it seems to need is this commit.environment-py3.ymlfile to manage the Python 3 dependencies. It's ugly to list them in yet another place but I think it's necessary given things won't be exactly the same.fts-restDoesn't seem to support Python 3 at all. I've made enough changes in a fork to make it possible import and that's what I use here. Porting it properly to usingsixshould only take a few hours but I didn't find any tests and we should ask the developers to see what their plans are.BEGINRELEASENOTES
*Python 3
NEW: Run pytest test collection for Python 3
ENDRELEASENOTES